package com.smfx.yxt.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.smfx.yxt.daoSqlserver.TeacherOrderFoodMapper;
import com.smfx.yxt.model.Grid;
import com.smfx.yxt.model.TeacherOrderFood;
import com.smfx.yxt.page.OrderBy;
import com.smfx.yxt.page.Page;
import com.smfx.yxt.reqVo.TeacherOrderFoodReqVO;
import com.smfx.yxt.service.ITeacherOrderFoodService;
import com.smfx.yxt.view.TeacherOrderFoodTotalView;

@Service("teacherOrderFoodService")
public class TeacherOrderFoodServiceImpl implements ITeacherOrderFoodService {

	@Autowired
	private TeacherOrderFoodMapper teacherOrderFoodMapper;
	
	@Override
	public int insertSelective(TeacherOrderFood record) {
		return teacherOrderFoodMapper.insertSelective(record);
	}

	@Override
	public TeacherOrderFood selectByPrimaryKey(Integer id) {
		return teacherOrderFoodMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(TeacherOrderFood record) {
		return teacherOrderFoodMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public List<TeacherOrderFood> selectTeacherListByDate(TeacherOrderFoodReqVO vo) {
		return teacherOrderFoodMapper.selectTeacherListByDate(vo);
	}

	@Override
	public List<TeacherOrderFoodTotalView> selectTotalByDate(String orderDate) {
		return teacherOrderFoodMapper.selectTotalByDate(orderDate);
	}

	@Override
	public Grid selectOrderListByParam(TeacherOrderFoodReqVO vo) {
		Grid grid = new Grid();
		Page<TeacherOrderFood> page = new Page<>();
		page.setPageNo(vo.getPage());
		page.setPageSize(vo.getRows());
		page.setParams(vo);
		List<OrderBy> orList = new ArrayList<>();
		orList.add(new OrderBy("ORDER_TYPE","desc"));
		orList.add(new OrderBy("TEACHER_NAME"));
		page.setSorts(orList);
		List<TeacherOrderFood> list = teacherOrderFoodMapper.selectOrderListByParam(page);
		grid.setRows(list);
		grid.setTotal(page.getTotalRecord());
		return grid;
	}

}
